// index.js
// 获取应用实例
import {
  post,
  get,
  put
} from '../../utils/request'
import {
  APIS
} from '../../utils/api';
const app = getApp();

Page({
  data: {
    list: [],
    system: {}
  },
  onLoad() {
    this.getShopData();
    this.getShopInfo();
  },
  getShopData() {
    get(APIS.shop).then(res => {
      const list = res.data;
      this.setData({
        list
      });
    })
  },
  getShopInfo() {
    const sid = wx.getStorageSync('currentShop');
    if (sid) {
      get(`${APIS.shop}/${sid}`).then(res => {
        const { data, system } = res;
        this.setData({
          info: {
            ...data,
            tag: data.tag.split(','),
          },
          system
        });
      })
    }
  },
  onShareAppMessage() {
    return getApp().globalData.shareMessage
  }
})